resource: Add System RAM resource type
Subsystems (25)
PATCH v2 1/16 resource: Add System RAM resource type
I/O resource type, IORESOURCE_MEM, is used for all types of memory-mapped ranges, ex. System RAM, System ROM, Video RAM, Persistent Memory, PCI Bus, PCI MMCONFIG, ACPI Tables, IOAPIC, reserved, and so on. This requires walk_system_ram_range(), walk_system_ram_res(), and region_intersects() to use strcmp() against string "System RAM" to search for System RAM ranges in the iomem table, which is inefficient. __ioremap_caller() and reserve_memtype() on x86, for instance, call walk_system_ram_range() for every request to check if a given range is in System RAM ranges.
However, adding a new I/O resource type for System RAM is not a viable option [1]. There are approx. 3800 references to IORESOURCE_MEM in the kernel/drivers, which make it very difficult to distinguish their usages between new type and IORESOURCE_MEM. The I/O resource types are also used by the PNP subsystem. Therefore, this patch introduces an extended I/O resource type, IORESOURCE_SYSTEM_RAM, which consists of IORESOURCE_MEM and a new modifier flag IORESOURCE_SYSRAM [2].
To keep the code 'if (resource_type(r) == IORESOURCE_MEM)' to work continuously for System RAM, resource_ext_type() is added for extracting extended type bit(s).
Link[1]: http://lkml.kernel.org/r/<[email protected]>
Link[2]: http://lkml.kernel.org/r/<CA+55aFy4WQrWexC4u2LxX9Mw2NVoznw7p3Yh=iF4Xtf7zKWnRw@mail.gmail.com>
--- include/linux/ioport.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/ioport.h +11 -0
@@ -49,12 +49,19 @@ struct resource {#define IORESOURCE_WINDOW 0x00200000/* forwarded by bridge */ #define IORESOURCE_MUXED 0x00400000/* Resource is software muxed */ +#define IORESOURCE_EXT_TYPE_BITS 0x01000000/* Resource extended types */ +#define IORESOURCE_SYSRAM 0x01000000/* System RAM (modifier) */ +#define IORESOURCE_EXCLUSIVE 0x08000000/* Userland may not map this resource */ +#define IORESOURCE_DISABLED 0x10000000#define IORESOURCE_UNSET 0x20000000/* No address assigned yet */ #define IORESOURCE_AUTO 0x40000000#define IORESOURCE_BUSY 0x80000000/* Driver has marked this resource busy */ +/* I/O resource extended types */ +#define IORESOURCE_SYSTEM_RAM (IORESOURCE_MEM|IORESOURCE_SYSRAM) +/* PnP IRQ specific bits (IORESOURCE_BITS) */ #define IORESOURCE_IRQ_HIGHEDGE (1<<0)#define IORESOURCE_IRQ_LOWEDGE (1<<1)
@@ -170,6 +177,10 @@ static inline unsigned long resource_type(const struct resource *res) {return res->flags &IORESOURCE_TYPE_BITS ; } +static inline unsigned long resource_ext_type (const struct resource *res) +{ +return res->flags &IORESOURCE_EXT_TYPE_BITS ; +}/* True iff r1 completely contains r2 */ static inline bool resource_contains (struct resource *r1,struct resource *r2) {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 2/16 resource: make resource flags handled properly
I/O resource flags consist of I/O resource types and modifier bits. Therefore, checking an I/O resource type in 'flags' must be performed with a bitwise operation.
Fix find_next_iomem_res() and region_intersects() that simply compare 'flags' against a given value.
Also change __request_region() to set 'res->flags' from resource_type() and resource_ext_type() of the parent, so that children nodes will inherit the extended I/O resource type.
--- kernel/resource.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/resource.c +4 -3
@@ -358,7 +358,7 @@ static int find_next_iomem_res(struct resource *res, char *name,read_lock (&resource_lock);for (p = iomem_resource.child; p; p =next_resource (p, sibling_only)) { -if (p->flags != res->flags) +if ((p->flags & res->flags) != res->flags)continue ;if (name &&strcmp (p->name, name))continue ;
@@ -519,7 +519,8 @@ int region_intersects(resource_size_t start, size_t size, const char *name)read_lock (&resource_lock);for (p = iomem_resource.child; p ; p = p->sibling) { -bool is_type =strcmp (p->name, name) ==0 && p->flags == flags; +bool is_type =strcmp (p->name, name) ==0 && + ((p->flags & flags) == flags);if (start >= p->start && start <= p->end) is_type ? type++ : other++;
@@ -1071,7 +1072,7 @@ struct resource * __request_region(struct resource *parent, res->name = name; res->start = start; res->end = start + n -1 ; - res->flags =resource_type (parent); + res->flags =resource_type (parent) |resource_ext_type (parent); res->flags |=IORESOURCE_BUSY | flags;write_lock (&resource_lock);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 3/16 resource: Add I/O resource descriptor
In reply to Toshi Kaniwalk_iomem_res() and region_intersects() still need to use strcmp() for searching a resource entry by @name in the iomem table.
This patch introduces I/O resource descriptor, 'desc' in struct resoruce, for the iomem search interfaces. Drivers can assign their unique descritor to a range when they support the search interfaces. Otherwise, 'desc' is set to IORES_DESC_NONE (0). This avoids changing most of the drivers as they typically allocate resource entries statically, or by calling alloc_resource(), kzalloc(), or alloc_bootmem_low(), which set the field to zero by default. A later patch will address some drivers that use kmalloc() without zero'ing the field.
Also change release_mem_region_adjustable() to set 'desc' when its resource entry gets separated. Other resource interfaces are also changed to initialize 'desc' explicitly although alloc_resource() sets it to 0.
--- include/linux/ioport.h | 19 +++++++++++++++++++ kernel/resource.c | 5 +++++ 2 files changed, 24 insertions(+)
include/linux/ioport.h +19 -0
@@ -20,6 +20,7 @@ struct resource {resource_size_t end;const char *name;unsigned long flags; +unsigned long desc;struct resource *parent, *sibling, *child; };
@@ -112,6 +113,23 @@ struct resource {/* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */ #define IORESOURCE_PCI_FIXED (1<<4)/* Do not move resource */ +/* +* I/O Resource Descriptors +* +* Descriptors are used by walk_iomem_res_desc() and region_intersects() +* for searching a specific resource range in the iomem table. Assign +* a new descriptor when a resource range supports the search interfaces. +* Otherwise, resource.desc must be set to IORES_DESC_NONE (0). +*/ +enum { +IORES_DESC_NONE =0 , +IORES_DESC_CRASH_KERNEL =1 , +IORES_DESC_ACPI_TABLES =2 , +IORES_DESC_ACPI_NV_STORAGE =3 , +IORES_DESC_GART =4 , +IORES_DESC_PERSISTENT_MEMORY =5 , +IORES_DESC_PERSISTENT_MEMORY_LEGACY =6 , +};/* helpers to define resources */ #define DEFINE_RES_NAMED (_start, _size, _name, _flags) \
@@ -120,6 +138,7 @@ struct resource { .end = (_start) + (_size) - 1, \ .name = (_name), \ .flags = (_flags), \ + .desc = IORES_DESC_NONE, \ }#define DEFINE_RES_IO_NAMED (_start, _size, _name) \
kernel/resource.c +5 -0
@@ -949,6 +949,7 @@ static void __init __reserve_region_with_split(struct resource *root, res->start = start; res->end = end; res->flags =IORESOURCE_BUSY ; + res->desc =IORES_DESC_NONE ;while (1 ) {
@@ -983,6 +984,7 @@ static void __init __reserve_region_with_split(struct resource *root, next_res->start = conflict->end +1 ; next_res->end = end; next_res->flags =IORESOURCE_BUSY ; + next_res->desc =IORES_DESC_NONE ; } }else { res->start = conflict->end +1 ;
@@ -1074,6 +1076,7 @@ struct resource * __request_region(struct resource *parent, res->end = start + n -1 ; res->flags =resource_type (parent) |resource_ext_type (parent); res->flags |=IORESOURCE_BUSY | flags; + res->desc =IORES_DESC_NONE ;write_lock (&resource_lock);
@@ -1238,6 +1241,7 @@ int release_mem_region_adjustable(struct resource *parent, new_res->start = end +1 ; new_res->end = res->end; new_res->flags = res->flags; + new_res->desc = res->desc; new_res->parent = res->parent; new_res->sibling = res->sibling; new_res->child =NULL ;
@@ -1413,6 +1417,7 @@ static int __init reserve_setup(char *str) res->start = io_start; res->end = io_start + io_num -1 ; res->flags =IORESOURCE_BUSY ; + res->desc =IORES_DESC_NONE ; res->child =NULL ;if (request_resource (res->start >=0x10000 ? &iomem_resource : &ioport_resource, res) ==0 ) reserved = x+1 ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 4/16 x86/e820: Set System RAM type and descriptor
In reply to Toshi KaniChange e820_reserve_resources() to set 'flags' and 'desc' from e820 types.
IORESOURCE_SYSTEM_RAM is set to 'flags' for System RAM, which are E820_RESERVED_KERN and E820_RAM. IORESOURCE_SYSTEM_RAM is also set to "Kernel data", "Kernel code", and "Kernel bss", which are children nodes of System RAM.
I/O resource descriptor is set to 'desc' for entries that are (and will be) target ranges of walk_iomem_res() and region_intersects().
--- arch/x86/kernel/e820.c | 38 +++++++++++++++++++++++++++++++++++++- arch/x86/kernel/setup.c | 6 +++--- 2 files changed, 40 insertions(+), 4 deletions(-)
arch/x86/kernel/e820.c +37 -1
@@ -925,6 +925,41 @@ static const char *e820_type_to_string(int e820_type) } } +static unsigned long e820_type_to_iomem_type (int e820_type) +{ +switch (e820_type) { +case E820_RESERVED_KERN : +case E820_RAM : +return IORESOURCE_SYSTEM_RAM ; +case E820_ACPI : +case E820_NVS : +case E820_UNUSABLE : +case E820_PRAM : +case E820_PMEM : +default : +return IORESOURCE_MEM ; + } +} + +static unsigned long e820_type_to_iores_desc (int e820_type) +{ +switch (e820_type) { +case E820_ACPI : +return IORES_DESC_ACPI_TABLES ; +case E820_NVS : +return IORES_DESC_ACPI_NV_STORAGE ; +case E820_PMEM : +return IORES_DESC_PERSISTENT_MEMORY ; +case E820_PRAM : +return IORES_DESC_PERSISTENT_MEMORY_LEGACY ; +case E820_RESERVED_KERN : +case E820_RAM : +case E820_UNUSABLE : +default : +return IORES_DESC_NONE ; + } +} +static bool do_mark_busy (u32 type,struct resource *res) {/* this is the legacy bios/dos rom-shadow + mmio region */
@@ -967,7 +1002,8 @@ void __init e820_reserve_resources(void) res->start = e820.map[i].addr; res->end = end; - res->flags =IORESOURCE_MEM ; + res->flags =e820_type_to_iomem_type (e820.map[i].type); + res->desc =e820_type_to_iores_desc (e820.map[i].type);/* * don't register the region that could be conflicted with
arch/x86/kernel/setup.c +3 -3
@@ -152,21 +152,21 @@ static struct resource data_resource = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource bss_resource = { .name ="Kernel bss" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 5/16 ia64: Set System RAM type and descriptor
In reply to Toshi KaniChange efi_initialize_iomem_resources() to set 'flags' and 'desc' from EFI memory types. IORESOURCE_SYSRAM, a modifier bit, is set to 'flags' for System RAM as IORESOURCE_MEM is already set. IORESOURCE_SYSTEM_RAM is defined as (IORESOURCE_MEM|IORESOURCE_SYSRAM). I/O resource descritor is set to 'desc' for "ACPI Non-volatile Storage" and "Persistent Memory".
Also set IORESOURCE_SYSTEM_RAM to 'flags' for "Kernel code", "Kernel data", and "Kernel bss".
--- arch/ia64/kernel/efi.c | 13 ++++++++++--- arch/ia64/kernel/setup.c | 6 +++--- 2 files changed, 13 insertions(+), 6 deletions(-)
arch/ia64/kernel/efi.c +10 -3
@@ -1178,7 +1178,7 @@ efi_initialize_iomem_resources(struct resource *code_resource,efi_memory_desc_t *md;u64 efi_desc_size;char *name; -unsigned long flags; +unsigned long flags, desc; efi_map_start =__va (ia64_boot_param->efi_memmap); efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
@@ -1193,6 +1193,8 @@ efi_initialize_iomem_resources(struct resource *code_resource,continue ; flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + desc =IORES_DESC_NONE ; +switch (md->type) {case EFI_MEMORY_MAPPED_IO :
@@ -1207,14 +1209,17 @@ efi_initialize_iomem_resources(struct resource *code_resource,if (md->attribute &EFI_MEMORY_WP ) { name ="System ROM" ; flags |=IORESOURCE_READONLY ; - }else if (md->attribute ==EFI_MEMORY_UC ) + }else if (md->attribute ==EFI_MEMORY_UC ) { name ="Uncached RAM" ; -else + }else { name ="System RAM" ; + flags |=IORESOURCE_SYSRAM ; + }break ;case EFI_ACPI_MEMORY_NVS : name ="ACPI Non-volatile Storage" ; + desc =IORES_DESC_ACPI_NV_STORAGE ;break ;case EFI_UNUSABLE_MEMORY :
@@ -1224,6 +1229,7 @@ efi_initialize_iomem_resources(struct resource *code_resource,case EFI_PERSISTENT_MEMORY : name ="Persistent Memory" ; + desc =IORES_DESC_PERSISTENT_MEMORY ;break ;case EFI_RESERVED_TYPE :
@@ -1246,6 +1252,7 @@ efi_initialize_iomem_resources(struct resource *code_resource, res->start = md->phys_addr; res->end = md->phys_addr +efi_md_size (md) -1 ; res->flags = flags; + res->desc = desc;if (insert_resource (&iomem_resource, res) <0 )kfree (res);
arch/ia64/kernel/setup.c +3 -3
@@ -80,17 +80,17 @@ unsigned long vga_console_membase;static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };unsigned long ia64_max_cacheline_size;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 6/16 arch: Set IORESOURCE_SYSTEM_RAM to System RAM
In reply to Toshi KaniSet IORESOURCE_SYSTEM_RAM to 'flags' of resource ranges with "System RAM", "Kernel code", "Kernel data", and "Kernel bss".
Note that:
- IORESOURCE_SYSRAM (i.e. modifier bit) is set to 'flags' when IORESOURCE_MEM is already set. IORESOURCE_SYSTEM_RAM is defined as (IORESOURCE_MEM|IORESOURCE_SYSRAM).
- Some archs do not set 'flags' for children nodes, such as "Kernel code". This patch does not change 'flags' in this case.
--- arch/arm/kernel/setup.c | 6 +++--- arch/arm64/kernel/setup.c | 6 +++--- arch/avr32/kernel/setup.c | 6 +++--- arch/m32r/kernel/setup.c | 4 ++-- arch/mips/kernel/setup.c | 10 ++++++---- arch/parisc/mm/init.c | 6 +++--- arch/powerpc/mm/mem.c | 2 +- arch/s390/kernel/setup.c | 8 ++++---- arch/score/kernel/setup.c | 2 +- arch/sh/kernel/setup.c | 8 ++++---- arch/sparc/mm/init_64.c | 8 ++++---- arch/tile/kernel/setup.c | 11 ++++++++--- arch/unicore32/kernel/setup.c | 6 +++--- 13 files changed, 45 insertions(+), 38 deletions(-)
arch/arm/kernel/setup.c +3 -3
@@ -173,13 +173,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } };
@@ -781,7 +781,7 @@ static void __init request_standard_resources(const struct machine_desc *mdesc) res->name ="System RAM" ; res->start =__pfn_to_phys (memblock_region_memory_base_pfn (region)); res->end =__pfn_to_phys (memblock_region_memory_end_pfn (region)) -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);
arch/arm64/kernel/setup.c +3 -3
@@ -73,13 +73,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } };
@@ -210,7 +210,7 @@ static void __init request_standard_resources(void) res->name ="System RAM" ; res->start =__pfn_to_phys (memblock_region_memory_base_pfn (region)); res->end =__pfn_to_phys (memblock_region_memory_end_pfn (region)) -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);
arch/avr32/kernel/setup.c +3 -3
@@ -49,13 +49,13 @@ static struct resource __initdata kernel_data = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM, + .flags = IORESOURCE_SYSTEM_RAM, };static struct resource __initdata kernel_code = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_MEM , + .flags =IORESOURCE_SYSTEM_RAM , .sibling = &kernel_data, };
@@ -134,7 +134,7 @@ add_physical_memory(resource_size_t start, resource_size_t end) new->start = start; new->end = end; new->name ="System RAM" ; - new->flags =IORESOURCE_MEM ; + new->flags =IORESOURCE_SYSTEM_RAM ; *pprev = new; }
arch/m32r/kernel/setup.c +2 -2
@@ -70,14 +70,14 @@ static struct resource data_resource = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };unsigned long memory_start;
arch/mips/kernel/setup.c +6 -4
@@ -732,21 +732,23 @@ static void __init resource_init(void) end =HIGHMEM_START -1 ; res =alloc_bootmem (sizeof (struct resource )); + + res->start = start; + res->end = end; + res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; +switch (boot_mem_map.map[i].type) {case BOOT_MEM_RAM :case BOOT_MEM_INIT_RAM :case BOOT_MEM_ROM_DATA : res->name ="System RAM" ; + res->flags |=IORESOURCE_SYSRAM ;break ;case BOOT_MEM_RESERVED :default : res->name ="reserved" ; } - res->start = start; - res->end = end; - - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);/*
arch/parisc/mm/init.c +3 -3
@@ -55,12 +55,12 @@ signed char pfnnid_map[PFNNID_MAP_MAX] __read_mostly;static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource pdcdata_resource = {
@@ -201,7 +201,7 @@ static void __init setup_bootmem(void) res->name ="System RAM" ; res->start = pmem_ranges[i].start_pfn <<PAGE_SHIFT ; res->end = res->start + (pmem_ranges[i].pages <<PAGE_SHIFT )-1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res); }
arch/powerpc/mm/mem.c +1 -1
@@ -541,7 +541,7 @@ static int __init add_system_ram_resources(void) res->name ="System RAM" ; res->start = base; res->end = base + size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;WARN_ON (request_resource (&iomem_resource, res) <0 ); } }
arch/s390/kernel/setup.c +4 -4
@@ -376,17 +376,17 @@ static void __init setup_lowcore(void)static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource __initdata *standard_resources[] = {
@@ -410,7 +410,7 @@ static void __init setup_resources(void)for_each_memblock (memory, reg) { res =alloc_bootmem_low (sizeof (*res)); - res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; + res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ; res->name ="System RAM" ; res->start = reg->base;
arch/score/kernel/setup.c +1 -1
@@ -101,7 +101,7 @@ static void __init resource_init(void) res->name ="System RAM" ; res->start =MEMORY_START ; res->end =MEMORY_START +MEMORY_SIZE -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);request_resource (res, &code_resource);
arch/sh/kernel/setup.c +4 -4
@@ -78,17 +78,17 @@ static char __initdata command_line[COMMAND_LINE_SIZE] = { 0, };static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM , + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , };unsigned long memory_start;
@@ -202,7 +202,7 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn, res->name ="System RAM" ; res->start = start; res->end = end -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;if (request_resource (&iomem_resource, res)) { pr_err("unable to request memory_resource 0x%lx 0x%lx\n",
arch/sparc/mm/init_64.c +4 -4
@@ -2862,17 +2862,17 @@ void hugetlb_setup(struct pt_regs *regs)static struct resource code_resource = { .name ="Kernel code" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource data_resource = { .name ="Kernel data" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static struct resource bss_resource = { .name ="Kernel bss" , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };static inline resource_size_t compute_kern_paddr (void *addr)
@@ -2908,7 +2908,7 @@ static int __init report_memory(void) res->name ="System RAM" ; res->start = pavail[i].phys_addr; res->end = pavail[i].phys_addr + pavail[i].reg_size -1 ; - res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; + res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ;if (insert_resource (&iomem_resource, res) <0 ) {pr_warn ("Resource insertion failed.\n" );
arch/tile/kernel/setup.c +8 -3
@@ -1632,14 +1632,14 @@ static struct resource data_resource = { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM };static struct resource code_resource = { .name ="Kernel code" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM };/*
@@ -1673,10 +1673,15 @@ insert_ram_resource(u64 start_pfn, u64 end_pfn, bool reserved)kzalloc (sizeof (struct resource ),GFP_ATOMIC );if (!res)return NULL ; - res->name = reserved ?"Reserved" :"System RAM" ; res->start = start_pfn <<PAGE_SHIFT ; res->end = (end_pfn <<PAGE_SHIFT ) -1 ; res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; +if (reserved) { + res->name ="Reserved" ; + }else { + res->name ="System RAM" ; + res->flags |=IORESOURCE_SYSRAM ; + }if (insert_resource (&iomem_resource, res)) {kfree (res);return NULL ;
arch/unicore32/kernel/setup.c +3 -3
@@ -72,13 +72,13 @@ static struct resource mem_res[] = { .name = "Kernel code", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM }, { .name = "Kernel data", .start = 0, .end = 0, - .flags = IORESOURCE_MEM + .flags = IORESOURCE_SYSTEM_RAM } };
@@ -211,7 +211,7 @@ request_standard_resources(struct meminfo *mi) res->name ="System RAM" ; res->start = mi->bank[i].start; res->end = mi->bank[i].start + mi->bank[i].size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;request_resource (&iomem_resource, res);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 7/16 kexec: Set IORESOURCE_SYSTEM_RAM to System RAM
In reply to Toshi KaniSet IORESOURCE_SYSTEM_RAM to 'flags' and IORES_DESC_CRASH_KERNEL to 'desc' of "Crash kernel" resource ranges, which are child nodes of System RAM.
Change crash_shrink_memory() to set IORESOURCE_SYSTEM_RAM for a System RAM range.
Change kexec_add_buffer() to call walk_iomem_res() with IORESOURCE_SYSTEM_RAM type for "Crash kernel".
--- kernel/kexec_core.c | 8 +++++--- kernel/kexec_file.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-)
kernel/kexec_core.c +5 -3
@@ -66,13 +66,15 @@ struct resource crashk_res = { .name = "Crash kernel", .start = 0, .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_MEM + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, + .desc = IORES_DESC_CRASH_KERNEL };struct resource crashk_low_res = { .name ="Crash kernel" , .start =0 , .end =0 , - .flags =IORESOURCE_BUSY |IORESOURCE_MEM + .flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM , + .desc =IORES_DESC_CRASH_KERNEL };int kexec_should_crash (struct task_struct *p)
@@ -934,7 +936,7 @@ int crash_shrink_memory(unsigned long new_size) ram_res->start = end; ram_res->end = crashk_res.end; - ram_res->flags =IORESOURCE_BUSY |IORESOURCE_MEM ; + ram_res->flags =IORESOURCE_BUSY |IORESOURCE_SYSTEM_RAM ; ram_res->name ="System RAM" ; crashk_res.end = end -1 ;
kernel/kexec_file.c +1 -1
@@ -523,7 +523,7 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,/* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type ==KEXEC_TYPE_CRASH ) ret =walk_iomem_res ("Crash kernel" , -IORESOURCE_MEM |IORESOURCE_BUSY , +IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , crashk_res.start, crashk_res.end, kbuf, locate_mem_hole_callback);else
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 8/16 xen, mm: Set IORESOURCE_SYSTEM_RAM to System RAM
In reply to Toshi KaniSet IORESOURCE_SYSTEM_RAM to 'flags' of struct resource entries with "System RAM".
--- drivers/xen/balloon.c | 2 +- mm/memory_hotplug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/xen/balloon.c +1 -1
@@ -257,7 +257,7 @@ static struct resource *additional_memory_resource(phys_addr_t size)return NULL ; res->name ="System RAM" ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; ret = allocate_resource(&iomem_resource, res, size, 0, -1,
mm/memory_hotplug.c +1 -1
@@ -136,7 +136,7 @@ static struct resource *register_memory_resource(u64 start, u64 size) res->name ="System RAM" ; res->start = start; res->end = start + size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;if (request_resource (&iomem_resource, res) <0 ) {pr_debug ("System RAM resource %pR cannot be added\n" , res);kfree (res);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [Xen-devel] [PATCH v2 08/16] xen, mm: Set IORESOURCE_SYSTEM_RAM to System RAM
Quoted 2 lines · Toshi Kani
Set
IORESOURCE_SYSTEM_RAMto 'flags' of struct resource entries with "System RAM".
[...]
drivers/xen/balloon.c static struct resource *additional_memory_resource(phys_addr_t size) · line 263
Quoted 11 lines
drivers/xen/balloon.c +1
-1@@ -257,7 +257,7 @@ static struct resource *additional_memory_resource(phys_addr_t size)return NULL ; res->name ="System RAM" ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; ret = allocate_resource(&iomem_resource, res, size, 0, -1,
David
Re: [PATCH v2 08/16] xen, mm: Set IORESOURCE_SYSTEM_RAM to System RAM
In reply to Toshi KaniQuoted 2 lines · Toshi Kani
Set
IORESOURCE_SYSTEM_RAMto 'flags' of struct resource entries with "System RAM".
[...]
drivers/xen/balloon.c static struct resource *additional_memory_resource(phys_addr_t size) · line 263
Quoted 11 lines
drivers/xen/balloon.c +1
-1@@ -257,7 +257,7 @@ static struct resource *additional_memory_resource(phys_addr_t size)return NULL ; res->name ="System RAM" ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; ret = allocate_resource(&iomem_resource, res, size, 0, -1,
David
PATCH v2 8/16 xen, mm: Set IORESOURCE_SYSTEM_RAM to System RAM
In reply to Toshi KaniSet IORESOURCE_SYSTEM_RAM to 'flags' of struct resource entries with "System RAM".
--- drivers/xen/balloon.c | 2 +- mm/memory_hotplug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/xen/balloon.c +1 -1
@@ -257,7 +257,7 @@ static struct resource *additional_memory_resource(phys_addr_t size)return NULL ; res->name ="System RAM" ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; ret = allocate_resource(&iomem_resource, res, size, 0, -1,
mm/memory_hotplug.c +1 -1
@@ -136,7 +136,7 @@ static struct resource *register_memory_resource(u64 start, u64 size) res->name ="System RAM" ; res->start = start; res->end = start + size -1 ; - res->flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res->flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ;if (request_resource (&iomem_resource, res) <0 ) {pr_debug ("System RAM resource %pR cannot be added\n" , res);kfree (res);
PATCH v2 9/16 drivers: Initialize resource entry to zero
In reply to Toshi KaniI/O resource descriptor, 'desc' added to struct resource, needs to be initialized to zero by default. Some drivers call kmalloc() to allocate a resource entry, but does not initialize it to zero by memset(). Change these drivers to call kzalloc(), instead.
--- drivers/acpi/acpi_platform.c | 2 +- drivers/parisc/eisa_enumerator.c | 4 ++-- drivers/rapidio/rio.c | 8 ++++---- drivers/sh/superhyway/superhyway.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
drivers/acpi/acpi_platform.c +1 -1
@@ -62,7 +62,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)if (count <0 ) {return NULL ; }else if (count >0 ) { - resources =kmalloc (count *sizeof (struct resource ), + resources =kzalloc (count *sizeof (struct resource ),GFP_KERNEL );if (!resources) {dev_err (&adev->dev,"No memory for resources\n" );
drivers/parisc/eisa_enumerator.c +2 -2
@@ -91,7 +91,7 @@ static int configure_memory(const unsigned char *buf,for (i=0 ;i<HPEE_MEMORY_MAX_ENT ;i++) { c =get_8 (buf+len); -if (NULL != (res =kmalloc (sizeof (struct resource ),GFP_KERNEL ))) { +if (NULL != (res =kzalloc (sizeof (struct resource ),GFP_KERNEL ))) {int result; res->name = name;
@@ -183,7 +183,7 @@ static int configure_port(const unsigned char *buf, struct resource *io_parent,for (i=0 ;i<HPEE_PORT_MAX_ENT ;i++) { c =get_8 (buf+len); -if (NULL != (res =kmalloc (sizeof (struct resource ),GFP_KERNEL ))) { +if (NULL != (res =kzalloc (sizeof (struct resource ),GFP_KERNEL ))) { res->name = board; res->start =get_16 (buf+len+1 ); res->end =get_16 (buf+len+1 )+(c&HPEE_PORT_SIZE_MASK )+1 ;
drivers/rapidio/rio.c +4 -4
@@ -117,7 +117,7 @@ int rio_request_inb_mbox(struct rio_mport *mport,if (mport->ops->open_inb_mbox ==NULL ) goto out; - res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); + res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_mbox_res (res, mbox, mbox);
@@ -185,7 +185,7 @@ int rio_request_outb_mbox(struct rio_mport *mport,if (mport->ops->open_outb_mbox ==NULL ) goto out; - res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); + res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_mbox_res (res, mbox, mbox);
@@ -285,7 +285,7 @@ int rio_request_inb_dbell(struct rio_mport *mport, {int rc =0 ; -struct resource *res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); +struct resource *res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_dbell_res (res, start, end);
@@ -360,7 +360,7 @@ int rio_release_inb_dbell(struct rio_mport *mport, u16 start, u16 end)struct resource *rio_request_outb_dbell (struct rio_dev *rdev,u16 start,u16 end) { -struct resource *res =kmalloc (sizeof (struct resource ),GFP_KERNEL ); +struct resource *res =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (res) {rio_init_dbell_res (res, start, end);
drivers/sh/superhyway/superhyway.c +1 -1
@@ -66,7 +66,7 @@ int superhyway_add_device(unsigned long base, struct superhyway_device *sdev,superhyway_read_vcr (dev, base, &dev->vcr);if (!dev->resource) { - dev->resource =kmalloc (sizeof (struct resource ),GFP_KERNEL ); + dev->resource =kzalloc (sizeof (struct resource ),GFP_KERNEL );if (!dev->resource) {kfree (dev);return -ENOMEM ;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 09/16] drivers: Initialize resource entry to zero
Quoted 9 lines · Toshi Kani
I/O resource descriptor, 'desc' added to struct resource, needs to be initialized to zero by default. Some drivers call
kmalloc()to allocate a resource entry, but does not initialize it to zero bymemset(). Change these drivers to callkzalloc(), instead.Signed-off-by Toshi Kani <[email protected]>
Quoted 6 lines
--- drivers/acpi/acpi_platform.c | 2 +- drivers/parisc/eisa_enumerator.c | 4 ++-- drivers/rapidio/rio.c | 8 ++++---- drivers/sh/superhyway/superhyway.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
drivers/sh/ portion:
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 10/16 resource: Change walk_system_ram to use System RAM type
In reply to Toshi KaniNow that all System RAM resource entries have been initialized to IORESOURCE_SYSTEM_RAM type, change walk_system_ram_res() and walk_system_ram_range() to call find_next_iomem_res() by setting IORESOURCE_SYSTEM_RAM to @res.flags and NULL to @name. With this change, they walk through the iomem table to find System RAM ranges without using strcmp().
No functional change is made to the interfaces.
--- kernel/resource.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
kernel/resource.c +11 -11
@@ -415,9 +415,9 @@ int walk_iomem_res(char *name, unsigned long flags, u64 start, u64 end, }/* -* This function calls callback against all memory range of "System RAM" -* which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. -* Now, this function is only for "System RAM". This function deals with +* This function calls callback against all memory range of System RAM +* which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY. +* Now, this function is only for System RAM. This function deals with * full ranges and not pfn. If resources are not pfn aligned, dealing * with pfn can truncate ranges. */
@@ -430,10 +430,10 @@ int walk_system_ram_res(u64 start, u64 end, void *arg, res.start = start; res.end = end; - res.flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res.flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; orig_end = res.end;while ((res.start < res.end) && - (!find_next_iomem_res (&res,"System RAM" , true))) { + (!find_next_iomem_res (&res,NULL , true))) { ret = (*func)(res.start, res.end, arg);if (ret)break ;
@@ -446,9 +446,9 @@ int walk_system_ram_res(u64 start, u64 end, void *arg,#if !defined(CONFIG_ARCH_HAS_WALK_MEMORY )/* -* This function calls callback against all memory range of "System RAM" -* which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. -* Now, this function is only for "System RAM". +* This function calls callback against all memory range of System RAM +* which are marked as IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY. +* Now, this function is only for System RAM. */ int walk_system_ram_range (unsigned long start_pfn,unsigned long nr_pages,void *arg,int (*func)(unsigned long ,unsigned long ,void *))
@@ -460,10 +460,10 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, res.start = (u64 ) start_pfn <<PAGE_SHIFT ; res.end = ((u64)(start_pfn + nr_pages) <<PAGE_SHIFT ) -1 ; - res.flags =IORESOURCE_MEM |IORESOURCE_BUSY ; + res.flags =IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY ; orig_end = res.end;while ((res.start < res.end) && - (find_next_iomem_res (&res,"System RAM" , true) >=0 )) { + (find_next_iomem_res (&res,NULL , true) >=0 )) { pfn = (res.start +PAGE_SIZE -1 ) >>PAGE_SHIFT ; end_pfn = (res.end +1 ) >>PAGE_SHIFT ;if (end_pfn > pfn)
@@ -484,7 +484,7 @@ static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) }/* * This generic page_is_ram() returns true if specified address is -* registered as "System RAM" in iomem_resource list. +* registered as System RAM in iomem_resource list. */ int __weak page_is_ram (unsigned long pfn) {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 11/16 arm/samsung: Change s3c_pm_run_res() to use System RAM type
In reply to Toshi KaniChange s3c_pm_run_res() to check with IORESOURCE_SYSTEM_RAM, instead of strcmp() with "System RAM", to walk through System RAM ranges in the iomem table.
No functional change is made to the interface.
--- arch/arm/plat-samsung/pm-check.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/plat-samsung/pm-check.c +2 -2
@@ -53,8 +53,8 @@ static void s3c_pm_run_res(struct resource *ptr, run_fn_t fn, u32 *arg)if (ptr->child !=NULL )s3c_pm_run_res (ptr->child, fn, arg); -if ((ptr->flags &IORESOURCE_MEM ) && -strcmp (ptr->name,"System RAM" ) ==0 ) { +if ((ptr->flags &IORESOURCE_SYSTEM_RAM ) + ==IORESOURCE_SYSTEM_RAM ) {S3C_PMDBG ("Found system RAM at %08lx..%08lx\n" , (unsigned long )ptr->start, (unsigned long )ptr->end);
PATCH v2 12/16 memremap: Change region_intersects() to take @flags and @desc
In reply to Toshi KaniChange region_intersects() to identify a target with @flags and @desc, instead of @name with strcmp().
Change the callers of region_intersects(), memremap() and devm_memremap(), to set IORESOURCE_SYSTEM_RAM to @flags and IORES_DESC_NONE to @desc for searching System RAM.
Also, export region_intersects() so that the EINJ driver can call this function in a later patch.
--- include/linux/mm.h | 3 ++- kernel/memremap.c | 13 +++++++------ kernel/resource.c | 26 +++++++++++++++----------- 3 files changed, 24 insertions(+), 18 deletions(-)
include/linux/mm.h +2 -1
@@ -362,7 +362,8 @@ enum { REGION_MIXED, }; -int region_intersects (resource_size_t offset,size_t size,const char *type); +int region_intersects (resource_size_t offset,size_t size,unsigned long flags, +unsigned long desc);/* Support for virtually mapped pages */ struct page *vmalloc_to_page (const void *addr);
kernel/memremap.c +7 -6
@@ -44,7 +44,7 @@ static void *try_ram_remap(resource_size_t offset, size_t size)* being mapped does not have i/o side effects and the __iomem * annotation is not applicable. * -* MEMREMAP_WB - matches the default mapping for "System RAM" on +* MEMREMAP_WB - matches the default mapping for System RAM on * the architecture. This is usually a read-allocate write-back cache. * Morever, if MEMREMAP_WB is specified and the requested remap region is RAM * memremap() will bypass establishing a new mapping and instead return
@@ -53,11 +53,12 @@ static void *try_ram_remap(resource_size_t offset, size_t size)* MEMREMAP_WT - establish a mapping whereby writes either bypass the * cache or are written through to memory and never exist in a * cache-dirty state with respect to program visibility. Attempts to -* map "System RAM" with this mapping type will fail. +* map System RAM with this mapping type will fail. */ void *memremap (resource_size_t offset,size_t size,unsigned long flags) { -int is_ram =region_intersects (offset, size,"System RAM" ); +int is_ram =region_intersects (offset, size, +IORESOURCE_SYSTEM_RAM ,IORES_DESC_NONE );void *addr =NULL ;if (is_ram ==REGION_MIXED ) {
@@ -73,7 +74,7 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)* MEMREMAP_WB is special in that it can be satisifed * from the direct map. Some archs depend on the * capability of memremap() to autodetect cases where -* the requested range is potentially in "System RAM" +* the requested range is potentially in System RAM. */ if (is_ram ==REGION_INTERSECTS ) addr =try_ram_remap (offset, size);
@@ -85,7 +86,7 @@ void *memremap(resource_size_t offset, size_t size, unsigned long flags)* If we don't have a mapping yet and more request flags are * pending then we will be attempting to establish a new virtual * address mapping. Enforce that this mapping is not aliasing -* "System RAM" +* System RAM. */ if (!addr && is_ram ==REGION_INTERSECTS && flags) { WARN_ONCE(1, "memremap attempted on ram %pa size: %#lx\n",
@@ -163,7 +164,7 @@ static void devm_memremap_pages_release(struct device *dev, void *res)void *devm_memremap_pages (struct device *dev,struct resource *res) {int is_ram =region_intersects (res->start,resource_size (res), -"System RAM" ); +IORESOURCE_SYSTEM_RAM ,IORES_DESC_NONE );struct page_map *page_map;int error, nid;
kernel/resource.c +15 -11
@@ -496,31 +496,34 @@ EXPORT_SYMBOL_GPL(page_is_ram);* region_intersects() - determine intersection of region with known resources * @start: region start address * @size: size of region -* @name: name of resource (in iomem_resource) +* @flags: flags of resource (in iomem_resource) +* @desc: descriptor of resource (in iomem_resource) or IORES_DESC_NONE * * Check if the specified region partially overlaps or fully eclipses a -* resource identified by @name. Return REGION_DISJOINT if the region -* does not overlap @name, return REGION_MIXED if the region overlaps -* @type and another resource, and return REGION_INTERSECTS if the -* region overlaps @type and no other defined resource. Note, that -* REGION_INTERSECTS is also returned in the case when the specified -* region overlaps RAM and undefined memory holes. +* resource identified by @flags and @desc (optinal with IORES_DESC_NONE). +* Return REGION_DISJOINT if the region does not overlap @flags/@desc, +* return REGION_MIXED if the region overlaps @flags/@desc and another +* resource, and return REGION_INTERSECTS if the region overlaps @flags/@desc +* and no other defined resource. Note, that REGION_INTERSECTS is also +* returned in the case when the specified region overlaps RAM and undefined +* memory holes. * * region_intersect() is used by memory remapping functions to ensure * the user is not remapping RAM and is a vast speed up over walking * through the resource table page by page. */ -int region_intersects (resource_size_t start,size_t size,const char *name) +int region_intersects (resource_size_t start,size_t size,unsigned long flags, +unsigned long desc) { -unsigned long flags =IORESOURCE_MEM |IORESOURCE_BUSY ;resource_size_t end = start + size -1 ;int type =0 ;int other =0 ;struct resource *p;read_lock (&resource_lock);for (p = iomem_resource.child; p ; p = p->sibling) { -bool is_type =strcmp (p->name, name) ==0 && - ((p->flags & flags) == flags); +bool is_type = (((p->flags & flags) == flags) && + ((desc ==IORES_DESC_NONE ) || + (desc == p->desc)));if (start >= p->start && start <= p->end) is_type ? type++ : other++;
@@ -539,6 +542,7 @@ int region_intersects(resource_size_t start, size_t size, const char *name)return REGION_DISJOINT ; } +EXPORT_SYMBOL_GPL (region_intersects);void __weak arch_remove_reservations (struct resource *avail) {
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 13/16 resource: Add walk_iomem_res_desc()
In reply to Toshi KaniAdd a new interface, walk_iomem_res_desc(), which walks through the iomem table by identifying a target with @flags and @desc. This interface provides the same functionality as walk_iomem_res(), but does not use strcmp() to @name for better efficiency.
walk_iomem_res() is deprecated, but is maintained for backward compatibility since walk_iomem_res_desc() requires 'desc' of a target resource entry be initialized with its descriptor ID.
--- include/linux/ioport.h | 3 ++ kernel/resource.c | 58 ++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 7 deletions(-)
include/linux/ioport.h +3 -0
@@ -269,6 +269,9 @@ extern int walk_system_ram_res(u64 start, u64 end, void *arg, int (*func)(u64, u64, void *));extern int +walk_iomem_res_desc (unsigned long desc,unsigned long flags,u64 start,u64 end, +void *arg,int (*func)(u64 ,u64 ,void *)); +extern int walk_iomem_res (char *name,unsigned long flags,u64 start,u64 end,void *arg,int (*func)(u64 ,u64 ,void *));
kernel/resource.c +51 -7
101 lines not on this page · raw message
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 14/16 x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
In reply to Toshi KaniChange to call walk_iomem_res_desc() for searching resource entries with the following names:
"ACPI Tables"
"ACPI Non-volatile Storage"
"Persistent Memory (legacy)"
"Crash kernel"
Note, the caller of walk_iomem_res() with "GART" is left unchanged because this entry may be initialized by out-of-tree drivers, which do not have 'desc' set to IORES_DESC_GART.
--- arch/x86/kernel/crash.c | 4 ++-- arch/x86/kernel/pmem.c | 4 ++-- drivers/nvdimm/e820.c | 2 +- kernel/kexec_file.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-)
arch/x86/kernel/crash.c +2 -2
@@ -588,12 +588,12 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params)/* Add ACPI tables */ cmd.type =E820_ACPI ; flags =IORESOURCE_MEM |IORESOURCE_BUSY ; -walk_iomem_res ("ACPI Tables" , flags,0 ,-1 , &cmd, +walk_iomem_res_desc (IORES_DESC_ACPI_TABLES , flags,0 ,-1 , &cmd, memmap_entry_callback);/* Add ACPI Non-volatile Storage */ cmd.type =E820_NVS ; -walk_iomem_res ("ACPI Non-volatile Storage" , flags,0 ,-1 , &cmd, +walk_iomem_res_desc (IORES_DESC_ACPI_NV_STORAGE , flags,0 ,-1 , &cmd, memmap_entry_callback);/* Add crashk_low_res region */
arch/x86/kernel/pmem.c +2 -2
@@ -13,11 +13,11 @@ static int found(u64 start, u64 end, void *data)static __init int register_e820_pmem (void ) { -char *pmem ="Persistent Memory (legacy)" ;struct platform_device *pdev;int rc; - rc =walk_iomem_res (pmem,IORESOURCE_MEM ,0 ,-1 ,NULL , found); + rc =walk_iomem_res_desc (IORES_DESC_PERSISTENT_MEMORY_LEGACY , +IORESOURCE_MEM ,0 ,-1 ,NULL , found);if (rc <=0 )return 0 ;
drivers/nvdimm/e820.c +1 -1
@@ -55,7 +55,7 @@ static int e820_pmem_probe(struct platform_device *pdev)for (p = iomem_resource.child; p ; p = p->sibling) {struct nd_region_desc ndr_desc; -if (strncmp (p->name,"Persistent Memory (legacy)" ,26 ) !=0 ) +if (p->desc !=IORES_DESC_PERSISTENT_MEMORY_LEGACY )continue ;memset (&ndr_desc,0 ,sizeof (ndr_desc));
kernel/kexec_file.c +4 -4
@@ -522,10 +522,10 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,/* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type ==KEXEC_TYPE_CRASH ) - ret =walk_iomem_res ("Crash kernel" , -IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , - crashk_res.start, crashk_res.end, kbuf, - locate_mem_hole_callback); + ret =walk_iomem_res_desc (IORES_DESC_CRASH_KERNEL , +IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , + crashk_res.start, crashk_res.end, kbuf, + locate_mem_hole_callback);else ret =walk_system_ram_res (0 ,-1 , kbuf, locate_mem_hole_callback);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Borislav Petkov
maintainerRe: [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
Quoted 10 lines · Toshi Kani
Change to call
walk_iomem_res_desc()for searching resource entries with the following names:
"ACPI Tables"
"ACPI Non-volatile Storage"
"Persistent Memory (legacy)"
"Crash kernel"Note, the caller of
walk_iomem_res()with "GART" is left unchanged because this entry may be initialized by out-of-tree drivers, which do not have 'desc' set toIORES_DESC_GART.
There's this out-of-tree bogus argument again. :\
Why do we care about out-of-tree drivers?
You can just as well fix the "GART" case too and kill walk_iomem_res() altogether...
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Re: [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
+ cc: kexec list
Quoted 12 lines · Borislav Petkov
Quoted 10 lines · Toshi Kani
Change to call
walk_iomem_res_desc()for searching resource entries with the following names:
"ACPI Tables"
"ACPI Non-volatile Storage"
"Persistent Memory (legacy)"
"Crash kernel"Note, the caller of
walk_iomem_res()with "GART" is left unchanged because this entry may be initialized by out-of-tree drivers, which do not have 'desc' set toIORES_DESC_GART.
Quoted 6 lines
There's this out-of-tree bogus argument again. :\
Why do we care about out-of-tree drivers?
You can just as well fix the "GART" case too and kill
walk_iomem_res()altogether...
Right, but I do not see any "GART" case in the upstream code, so I cannot change it...
Thanks,
-Toshi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 14/16] x86, nvdimm, kexec: Use walk_iomem_res_desc() for iomem search
Quoted 17 lines · Toshi Kani
+ cc: kexec list
Quoted 14 lines · Borislav Petkov
Quoted 10 lines · Toshi Kani
Change to call
walk_iomem_res_desc()for searching resource entries with the following names:
"ACPI Tables"
"ACPI Non-volatile Storage"
"Persistent Memory (legacy)"
"Crash kernel"Note, the caller of
walk_iomem_res()with "GART" is left unchanged because this entry may be initialized by out-of-tree drivers, which do not have 'desc' set toIORES_DESC_GART.There's this out-of-tree bogus argument again. :\
Quoted 7 lines
Quoted 4 lines
Why do we care about out-of-tree drivers?
You can just as well fix the "GART" case too and kill
walk_iomem_res()altogether...Right, but I do not see any "GART" case in the upstream code, so I cannot change it...
Hi, Toshi.
You can refer the below link that you may get a clue about GART. This is the fisrt time kexec-tools tried to support to ignore GART region in 2nd kernel.
http://lists.infradead.org/pipermail/kexec/2008-December/003096.html
Thanks
Minfei
Borislav Petkov
maintainerRe: [PATCH v2 14/16] x86, nvdimm, kexec: Use walk_iomem_res_desc() for iomem search
Quoted 5 lines · Minfei Huang
You can refer the below link that you may get a clue about GART. This is the fisrt time kexec-tools tried to support to ignore GART region in 2nd kernel.
http://lists.infradead.org/pipermail/kexec/2008-December/003096.html
So theoretically we could export that IORES_DESC* enum in an uapi header and move kexec-tools to use that.
However, I'm fuzzy on how exactly the whole compatibility thing is done with kexec-tools and the kernel. We probably would have to support newer kexec-tools on an older kernel and vice versa so I'd guess we should mark walk_iomem_res() deprecated so that people are encouraged to upgrade to newer kexec-tools...
Hmmm.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Re: [PATCH v2 14/16] x86, nvdimm, kexec: Use walk_iomem_res_desc() for iomem search
Hi, Boris
Quoted 7 lines · Borislav Petkov
Quoted 5 lines · Minfei Huang
You can refer the below link that you may get a clue about GART. This is the fisrt time kexec-tools tried to support to ignore GART region in 2nd kernel.
http://lists.infradead.org/pipermail/kexec/2008-December/003096.html
Quoted 8 lines
So theoretically we could export that IORES_DESC* enum in an uapi header and move kexec-tools to use that.
However, I'm fuzzy on how exactly the whole compatibility thing is done with kexec-tools and the kernel. We probably would have to support newer kexec-tools on an older kernel and vice versa so I'd guess we should mark
walk_iomem_res()deprecated so that people are encouraged to upgrade to newer kexec-tools...
Replied to Toshi old kernel will export the "GART" region for amd cards. So for old kernel and new kexec-tools we will have problem.
I think add the GART desc for compitibility purpose is doable, no?
Thanks
Dave
Borislav Petkov
maintainerRe: [PATCH v2 14/16] x86, nvdimm, kexec: Use walk_iomem_res_desc() for iomem search
Quoted 4 lines · Dave Young
Replied to Toshi old kernel will export the "GART" region for amd cards. So for old kernel and new kexec-tools we will have problem.
I think add the GART desc for compitibility purpose is doable, no?
Just read your other mails too. If I see it correctly, there's only one place which has "GART":
$ git grep -e \"GART\"
arch/x86/kernel/crash.c:235: walk_iomem_res("GART", IORESOURCE_MEM, 0, -1,So crash.c only excludes this region but the kernel doesn't create it. Right?
So we can kill that walk_iomem_res(), as you say. Which would be even nicer...
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Re: [PATCH v2 14/16] x86, nvdimm, kexec: Use walk_iomem_res_desc() for iomem search
Quoted 14 lines · Borislav Petkov
Quoted 5 lines · Dave Young
Replied to Toshi old kernel will export the "GART" region for amd cards.
So for old kernel and new kexec-tools we will have problem.I think add the GART desc for compitibility purpose is doable, no?
Just read your other mails too. If I see it correctly, there's only one place which has "GART":
$ git grep -e \"GART\" arch/x86/kernel/crash.c:235: walk_iomem_res("GART", IORESOURCE_MEM, 0, -1,
Quoted 5 lines
So
crash.conly excludes this region but the kernel doesn't create it. Right?So we can kill that
walk_iomem_res(), as you say. Which would be even nicer...
Agreed. As Dave suggested in the other thread, we can simply remove the walk_iomem_res("GART",) call in crash.c.
With this change, there will be no caller to walk_iomem_res(). Should we remove walk_iomem_res() altogether, or keep it for now as a deprecated func with the checkpatch check?
Thanks,
-Toshi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Borislav Petkov
maintainerRe: [PATCH v2 14/16] x86, nvdimm, kexec: Use walk_iomem_res_desc() for iomem search
Quoted 3 lines · Toshi Kani
With this change, there will be no caller to
walk_iomem_res(). Should we removewalk_iomem_res()altogether, or keep it for now as a deprecated func with the checkpatch check?
Yes, kill it on the spot so that people don't get crazy ideas.
Thanks!
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Re: [PATCH v2 14/16] x86, nvdimm, kexec: Use walk_iomem_res_desc() for iomem search
Quoted 6 lines · Borislav Petkov
Quoted 3 lines · Toshi Kani
With this change, there will be no caller to
walk_iomem_res(). Should we removewalk_iomem_res()altogether, or keep it for now as a deprecated func with the checkpatch check?Yes, kill it on the spot so that people don't get crazy ideas.
Will do.
Thanks!
-Toshi
Re: [PATCH v2 14/16] x86, nvdimm, kexec: Use walk_iomem_res_desc() for iomem search
In reply to Borislav PetkovQuoted 6 lines · Borislav Petkov
Quoted 4 lines · Dave Young
Replied to Toshi old kernel will export the "GART" region for amd cards. So for old kernel and new kexec-tools we will have problem.
I think add the GART desc for compitibility purpose is doable, no?
Quoted 8 lines
Just read your other mails too. If I see it correctly, there's only one place which has "GART":
$ git grep -e \"GART\" arch/x86/kernel/crash.c:235: walk_iomem_res("GART", IORESOURCE_MEM, 0, -1,So
crash.conly excludes this region but the kernel doesn't create it. Right?
Right.
Quoted 3 lines
So we can kill that
walk_iomem_res(), as you say. Which would be even nicer...
Yes, I think it is ok to kill walk_iomem_res()
Thanks
Dave
Re: [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
In reply to Toshi KaniCcing kexec maillist.
kernel/kexec_file.c int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz, · line 525
Quoted 13 lines · Toshi Kani
kernel/kexec_file.c +1
-4@@ -522,10 +522,10 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,/* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type ==KEXEC_TYPE_CRASH ) - ret =walk_iomem_res ("Crash kernel" , -IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , - crashk_res.start, crashk_res.end, kbuf, - locate_mem_hole_callback); + ret = walk_iomem_res_desc(IORES_DESC_CRASH_KERNEL,
Since crashk_res's desc has been assigned to IORES_DESC_CRASH_KERNEL, it is better to use crashk_res.desc, instead of using IORES_DESC_CRASH_KERNEL directly.
Thanks
Minfei
Quoted 6 lines
kernel/kexec_file.c +3
-0+IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , + crashk_res.start, crashk_res.end, kbuf, + locate_mem_hole_callback); else ret =walk_system_ram_res (0 ,-1 , kbuf, locate_mem_hole_callback);
Re: [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
Quoted 9 lines · Minfei Huang
Ccing kexec maillist.
Quoted 6 lines · Toshi Kani
kernel/kexec_file.c +0
-0@@ -522,10 +522,10 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz,
Quoted 11 lines
kernel/kexec_file.c int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz, · line 525
Quoted 7 lines
kernel/kexec_file.c +1
-4/* Walk the RAM ranges and allocate a suitable range for the buffer */ if (image->type ==KEXEC_TYPE_CRASH ) - ret =walk_iomem_res ("Crash kernel" , -IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , - crashk_res.start, crashk_res.end, kbuf, - locate_mem_hole_callback); + ret = walk_iomem_res_desc(IORES_DESC_CRASH_KERNEL,Since crashk_res's desc has been assigned to
IORES_DESC_CRASH_KERNEL, it is better to use crashk_res.desc, instead of usingIORES_DESC_CRASH_KERNELdirectly.
Sounds good. I will change it to use crashk_res.desc.
Thanks,
-Toshi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
In reply to Toshi KaniHi, Toshi,
Quoted 10 lines · Toshi Kani
Change to call
walk_iomem_res_desc()for searching resource entries with the following names:
"ACPI Tables"
"ACPI Non-volatile Storage"
"Persistent Memory (legacy)"
"Crash kernel"Note, the caller of
walk_iomem_res()with "GART" is left unchanged because this entry may be initialized by out-of-tree drivers, which do not have 'desc' set toIORES_DESC_GART.
Found below commit which initialize the GART entry:
commit 56dd669a138c40ea6cdae487f233430d12372767
Author: Aaron Durbin <[email protected]> Date: Tue Sep 26 10:52:40 2006 +0200
[PATCH] Insert GART region into resource map
Patch inserts the GART region into the iomem resource map. The GART will then be visible within /proc/iomem. It will also allow for other users utilizing the GART to subreserve the region (agp or IOMMU).
But later it was reverted:
commit 707d4eefbdb31f8e588277157056b0ce637d6c68
Author: Bjorn Helgaas <[email protected]> Date: Tue Mar 18 14:26:12 2014 -0600
Revert "[PATCH] Insert GART region into resource map"
This reverts commit 56dd669a138c, which makes the GART visible in /proc/iomem. This fixes a regression: e501b3d87f00 ("agp: Support 64-bit APBASE") exposed an existing problem with a conflict between the GART region and a PCI BAR region.
The GART addresses are bus addresses, not CPU addresses, and therefore should not be inserted in iomem_resource.
On many machines, the GART region is addressable by the CPU as well as by an AGP master, but CPU addressability is not required by the spec. On some of these machines, the GART is mapped by a PCI BAR, and in that case, the PCI core automatically inserts it into iomem_resource, just as it does for all BARs.
Inserting it here means we'll have a conflict if the PCI core later tries to claim the GART region, so let's drop the insertion here.
The conflict indirectly causes X failures, as reported by Jouni in the bugzilla below. We detected the conflict even before e501b3d87f00, but after it the AGP code (fix_northbridge()) uses the PCI resource (which is zeroed because of the conflict) instead of reading the BAR again.
Conflicts:
arch/x86_64/kernel/aperture.c
For amd64 agp, currently the region name is "aperture" instead:drivers/char/agp/amd64-agp.c: agp_aperture_valid()
This may not be the only case, but I doubt that anyone is testing this since long time ago kexec-tools excluding the 'GART' region. Kexec-tools and kexec_file may need update to use "aperture" if someone can test it.
I think adding an enum value for compatibility is reasonable, we do not care about third party drivers in mainline.
Thanks
Dave
Re: [PATCH v2 14/16] x86,nvdimm,kexec: Use walk_iomem_res_desc() for iomem search
Quoted 68 lines · Dave Young
Hi, Toshi,
Quoted 10 lines · Toshi Kani
Change to call
walk_iomem_res_desc()for searching resource entries with the following names:
"ACPI Tables"
"ACPI Non-volatile Storage"
"Persistent Memory (legacy)"
"Crash kernel"Note, the caller of
walk_iomem_res()with "GART" is left unchanged because this entry may be initialized by out-of-tree drivers, which do not have 'desc' set toIORES_DESC_GART.Found below commit which initialize the GART entry:
commit56dd669a138c40ea6cdae487f233430d12372767Author: Aaron Durbin <[email protected]> Date: Tue Sep 26 10:52:40 2006 +0200[PATCH] Insert GART region into resource map
Patch inserts the GART region into the iomem resource map. The GART will then be visible within
/proc/iomem. It will also allow for other users utilizing the GART to subreserve the region (agp or IOMMU).Signed-off-by Aaron Durbin <[email protected]>But later it was reverted:
commit707d4eefbdb31f8e588277157056b0ce637d6c68Author: Bjorn Helgaas <[email protected]> Date: Tue Mar 18 14:26:12 2014 -0600Revert "[PATCH] Insert GART region into resource map"
This reverts commit
56dd669a138c, which makes the GART visible in/proc/iomem. This fixes a regression:e501b3d87f00("agp: Support 64-bit APBASE") exposed an existing problem with a conflict between the GART region and a PCI BAR region.The GART addresses are bus addresses, not CPU addresses, and therefore should not be inserted in
iomem_resource.On many machines, the GART region is addressable by the CPU as well as by an AGP master, but CPU addressability is not required by the spec. On some of these machines, the GART is mapped by a PCI BAR, and in that case, the PCI core automatically inserts it into
iomem_resource, just as it does for all BARs.Inserting it here means we'll have a conflict if the PCI core later tries to claim the GART region, so let's drop the insertion here.
The conflict indirectly causes X failures, as reported by Jouni in the bugzilla below. We detected the conflict even before
e501b3d87f00, but after it the AGP code (fix_northbridge()) uses the PCI resource (which is zeroed because of the conflict) instead of reading the BAR again.Conflicts:
arch/x86_64/kernel/aperture.cFixes e501b3d87f00 agp: Support 64-bit APBASEReported-and-tested-by Jouni Mettälä <[email protected]>Signed-off-by Bjorn Helgaas <[email protected]>For amd64 agp, currently the region name is "aperture" instead:
drivers/char/agp/amd64-agp.c:agp_aperture_valid()
Quoted 6 lines
This may not be the only case, but I doubt that anyone is testing this since long time ago kexec-tools excluding the 'GART' region. Kexec-tools and
kexec_filemay need update to use "aperture" if someone can test it.I think adding an enum value for compatibility is reasonable, we do not care about third party drivers in mainline.
Hmm, rethink about it, the new kernel will not export "GART" regions thus the in-kernel loader should never see such regions as long as there's no other drivers exporting it. Thus dropping the code chunk in crash.c about 'GART' should be fine.
Thanks
Dave
PATCH v2 15/16 checkpatch: Add warning on deprecated walk_iomem_res
In reply to Toshi KaniUse of walk_iomem_res() is deprecated in new code. Change checkpatch.pl to check new use of walk_iomem_res() and suggest to use walk_iomem_res_desc() instead.
--- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+)
scripts/checkpatch.pl +6 -0
@@ -3424,6 +3424,12 @@ sub process { } } +# check for uses of walk_iomem_res() + if ($line =~ /\bwalk_iomem_res\(/) { + WARN("walk_iomem_res", + "Use of walk_iomem_res is deprecated, please use walk_iomem_res_desc instead\n" . $herecurr) + } + # check for new typedefs, only function parameters and sparse annotations # make sense. if ($line =~ /\btypedef\s/ &&
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Joe Perches
maintainerRe: [PATCH v2 15/16] checkpatch: Add warning on deprecated walk_iomem_res
Quoted 3 lines · Toshi Kani
Use of
walk_iomem_res()is deprecated in new code. Change checkpatch.pl to check new use ofwalk_iomem_res()and suggest to usewalk_iomem_res_desc()instead.
[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0
[]
Quoted 10 lines
scripts/checkpatch.pl +0
-0@@ -3424,6 +3424,12 @@ sub process { } }scripts/checkpatch.pl +6
-0+# check for uses of walk_iomem_res() + if ($line =~ /\bwalk_iomem_res\(/) { + WARN("walk_iomem_res", + "Use of walk_iomem_res is deprecated, please use walk_iomem_res_desc instead\n" . $herecurr) + } +
Quoted 3 lines
# check for new typedefs, only function parameters and sparse annotations # make sense. if ($line =~ /\btypedef\s/ &&
There are 6 uses of this function in the entire kernel tree. Why not just change them, remove the function and avoid this?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH v2 15/16] checkpatch: Add warning on deprecated walk_iomem_res
Quoted 11 lines · Joe Perches
Quoted 3 lines · Toshi Kani
Use of
walk_iomem_res()is deprecated in new code. Change checkpatch.pl to check new use ofwalk_iomem_res()and suggest to usewalk_iomem_res_desc()instead.[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0[]
Quoted 4 lines
scripts/checkpatch.pl +0
-0@@ -3424,6 +3424,12 @@ sub process { } }
Quoted 12 lines
scripts/checkpatch.pl sub process { · line 3435
Quoted 9 lines
scripts/checkpatch.pl +6
-0+# check for uses of walk_iomem_res() + if ($line =~ /\bwalk_iomem_res\(/) { + WARN("walk_iomem_res", + "Use of walk_iomem_res is deprecated, please use walk_iomem_res_desc instead\n" . $herecurr) + } + # check for new typedefs, only function parameters and sparse annotations # make sense. if ($line =~ /\btypedef\s/ &&There are 6 uses of this function in the entire kernel tree. Why not just change them, remove the function and avoid this?
Sorry, I should have put some background in the description. We have discussed if we can remove walk_iomem_res() in the thread below.
https://lkml.org/lkml/2015/12/23/248
But this may depend on how we deal with the last remaining caller, walk_iomem_res() with "GART", being discussed in the thread below. I will update according to the outcome.
https://lkml.org/lkml/2015/12/26/144
Thanks,
-Toshi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v2 16/16 ACPI/EINJ: Allow memory error injection to NVDIMM
In reply to Toshi KaniIn the case of memory error injection, einj_error_inject() checks if a target address is System RAM. Change this check to allow injecting a memory error to NVDIMM by calling region_intersects() with IORES_DESC_PERSISTENT_MEMORY. This enables memory error testing on both System RAM and NVDIMM.
In addition, page_is_ram() is replaced with region_intersects() with IORESOURCE_SYSTEM_RAM, so that it can verify a target address range with the requested size.
--- drivers/acpi/apei/einj.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/acpi/apei/einj.c +11 -4
@@ -519,7 +519,7 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, u64 param3, u64 param4) { int rc; -unsigned long pfn; +u64 base_addr, size;/* If user manually set "flags", make sure it is legal */ if (flags && (flags &
@@ -545,10 +545,17 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,/* * Disallow crazy address masks that give BIOS leeway to pick * injection address almost anywhere. Insist on page or -* better granularity and that target address is normal RAM. +* better granularity and that target address is normal RAM or +* NVDIMM. */ - pfn =PFN_DOWN (param1 & param2); -if (!page_is_ram (pfn) || ((param2 &PAGE_MASK ) !=PAGE_MASK )) + base_addr = param1 & param2; + size = ~param2 +1 ; + +if (((param2 &PAGE_MASK ) !=PAGE_MASK ) || + ((region_intersects (base_addr, size,IORESOURCE_SYSTEM_RAM , +IORES_DESC_NONE ) !=REGION_INTERSECTS ) && + (region_intersects (base_addr, size,IORESOURCE_MEM , +IORES_DESC_PERSISTENT_MEMORY ) !=REGION_INTERSECTS )))return -EINVAL ; inject:
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>